package com.example.makerspace.controller.notice;


import com.example.makerspace.dto.NoticeDTO;
import com.example.makerspace.dto.PageRequest;
import com.example.makerspace.dto.Pagination;
import com.example.makerspace.dto.Result;
import com.example.makerspace.service.NoticeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@Controller
@ResponseBody
@RequestMapping("/api/notice")
@Api(tags = "公告模块")
public class NoticeController {
    @Resource
    private NoticeService noticeService;


    @ApiOperation(value="增加公告接口",notes ="增加公告接口说明")
    @PostMapping("/addNotice")
    public Result addNotice(@RequestBody NoticeDTO noticeDTO) {
       return noticeService.addNotice(noticeDTO);
    }

    @ApiOperation(value="删除公告接口",notes ="删除公告接口说明")
    @GetMapping("/deleteNotice")
    public Result deleteNotice(@RequestParam("id") Integer id) {
        return noticeService.deleteNotice(id);
    }

    @ApiOperation(value="前台-查询所有公告接口",notes ="查询所有公告接口说明")
    @PostMapping("/selectNotices")
    public Result selectNotices(@RequestBody PageRequest pageRequest) {
        return noticeService.selectNotices(pageRequest);
    }

    @ApiOperation(value="后台-查询所有公告接口",notes ="查询所有公告接口说明")
    @PostMapping("/selectAllNotices")
    public Result selectAllNotices(@RequestBody PageRequest pageRequest) {
        return noticeService.selectAllNotices(pageRequest);
    }


    @ApiOperation(value="绑定公告到活动接口",notes ="绑定公告到活动接口说明")
    @PostMapping("/bindNotices")
    public Result bindNotices(@RequestBody NoticeDTO noticeDTO) {
        return noticeService.bindNotices(noticeDTO);
    }
}
